<?php
// No direct access to this file
defined ( '_JEXEC' ) or die ( 'Restricted access' );

// import Joomla view library
jimport ( 'joomla.application.component.view' );

class ManagerViewManager extends JView {
	
	function display($tpl = null) {		
		$Model = JModel::getInstance('Product', 'PimModel');
		
		$encrypted_code = isset($_POST['encrypted_code']) ? $_POST['encrypted_code'] : "";
		$search = "";
		
		if ($encrypted_code!="") {
			$search = $encrypted_code;
			
			$encrypted_code = md5($encrypted_code);
			$where = " WHERE `encrypted_code`='".$encrypted_code."'"; 
			$where.= " AND status = '" . ManagerHelper::PRODUCT_STATUS_CAN_USE_TEXT ."'";
		}
		
		$objconfig = $Model->getConfig();
		$limit = intval($objconfig['number_show_product']);
		$filter_order = 'id';
		$filter_order_Dir = 'DESC';
		$limitstart = 0;
		
        $Model->getData($total, $dbrow, $filter_order, $filter_order_Dir, $limitstart, $limit, $where);

		$this->assign('config', $objconfig);
        $this->assign('search', $search);
        $this->assign('TOTAL_ROW', $total);
        $this->assign('dbrow', $dbrow);
        
        parent::display ( $tpl );
	}	
}
